using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS.Plugin.Experiment;

public class FormAddSampleNumber : Form
{
	private IContainer components = null;

	private Label label1;

	private NumericUpDown nudNumers;

	private Button buttonOK;

	private Button buttonCannel;

	private RadioButton rdbNew;

	private RadioButton rdbCopy;

	private ComboBox cbSampleAdd;

	private Label label2;

	private GroupBox groupBox1;

	private GroupBox groupBox2;

	private Label label3;

	private ComboBox cbSamplePos;

	private RadioButton rdbInsert;

	private RadioButton rdbAppend;

	public int Numbers { get; set; }

	public int SrcPosition { get; set; }

	public int DestPosition { get; set; }

	public FormAddSampleNumber(IList<SamplesInfos> samples)
	{
		InitializeComponent();
		if (samples != null && samples.Count > 0)
		{
			foreach (SamplesInfos s in samples)
			{
				cbSampleAdd.Items.Add(s.label);
				cbSamplePos.Items.Add(s.label);
			}
			cbSampleAdd.SelectedIndex = 0;
			if (cbSamplePos.Items.Count > 0)
			{
				cbSamplePos.SelectedIndex = 0;
			}
		}
		SrcPosition = -1;
		DestPosition = -1;
		nudNumers.Value = 1m;
	}

	private void buttonOK_Click(object sender, EventArgs e)
	{
		Numbers = decimal.ToInt32(nudNumers.Value);
		base.DialogResult = DialogResult.OK;
	}

	private void buttonCannel_Click(object sender, EventArgs e)
	{
		base.DialogResult = DialogResult.Cancel;
	}

	private void rdbNew_CheckedChanged(object sender, EventArgs e)
	{
		if (rdbNew.Checked)
		{
			SrcPosition = -1;
		}
	}

	private void rdbCopy_CheckedChanged(object sender, EventArgs e)
	{
		cbSampleAdd.Enabled = rdbCopy.Checked;
		if (rdbCopy.Checked)
		{
			SrcPosition = cbSampleAdd.SelectedIndex;
		}
	}

	private void rdbAppend_CheckedChanged(object sender, EventArgs e)
	{
		if (rdbAppend.Checked)
		{
			DestPosition = -1;
		}
	}

	private void rdbInsert_CheckedChanged(object sender, EventArgs e)
	{
		cbSamplePos.Enabled = rdbInsert.Checked;
		if (rdbInsert.Checked)
		{
			DestPosition = cbSamplePos.SelectedIndex;
		}
	}

	private void cbSampleAdd_SelectedIndexChanged(object sender, EventArgs e)
	{
		SrcPosition = cbSampleAdd.SelectedIndex;
	}

	private void cbSamplePos_SelectedIndexChanged(object sender, EventArgs e)
	{
		DestPosition = cbSamplePos.SelectedIndex;
	}

	private void FormAddSampleNumber_Load(object sender, EventArgs e)
	{
		ApplyResources();
	}

	private void ApplyResources()
	{
		Text = Lang.Txt("FormAddSampleNumber.Title.Text");
		groupBox1.Text = Lang.Txt("FormAddSampleNumber.GroupBox.Add.Text");
		groupBox2.Text = Lang.Txt("FormAddSampleNumber.GroupBox.Position.Text");
		label1.Text = Lang.Txt("FormAddSampleNumber.Samplenumber.Text");
		label2.Text = Lang.Txt("FormAddSampleNumber.Copy.Text");
		label3.Text = Lang.Txt("FormAddSampleNumber.Insert.Text");
		rdbAppend.Text = Lang.Txt("FormAddSampleNumber.AddAfterTail.Text");
		rdbCopy.Text = Lang.Txt("FormAddSampleNumber.From.Text");
		rdbInsert.Text = Lang.Txt("FormAddSampleNumber.At.Text");
		rdbNew.Text = Lang.Txt("FormAddSampleNumber.NewSample.Text");
		buttonCannel.Text = Lang.Txt("FormAddSampleNumber.Button.Cancel.Text");
		buttonOK.Text = Lang.Txt("FormAddSampleNumber.Button.OK.Text");
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.label1 = new System.Windows.Forms.Label();
		this.nudNumers = new System.Windows.Forms.NumericUpDown();
		this.buttonOK = new System.Windows.Forms.Button();
		this.buttonCannel = new System.Windows.Forms.Button();
		this.rdbNew = new System.Windows.Forms.RadioButton();
		this.rdbCopy = new System.Windows.Forms.RadioButton();
		this.cbSampleAdd = new System.Windows.Forms.ComboBox();
		this.label2 = new System.Windows.Forms.Label();
		this.groupBox1 = new System.Windows.Forms.GroupBox();
		this.groupBox2 = new System.Windows.Forms.GroupBox();
		this.label3 = new System.Windows.Forms.Label();
		this.cbSamplePos = new System.Windows.Forms.ComboBox();
		this.rdbInsert = new System.Windows.Forms.RadioButton();
		this.rdbAppend = new System.Windows.Forms.RadioButton();
		((System.ComponentModel.ISupportInitialize)this.nudNumers).BeginInit();
		this.groupBox1.SuspendLayout();
		this.groupBox2.SuspendLayout();
		base.SuspendLayout();
		this.label1.AutoSize = true;
		this.label1.Location = new System.Drawing.Point(67, 111);
		this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label1.Name = "label1";
		this.label1.Size = new System.Drawing.Size(82, 15);
		this.label1.TabIndex = 0;
		this.label1.Text = "样品数量：";
		this.nudNumers.Location = new System.Drawing.Point(288, 105);
		this.nudNumers.Margin = new System.Windows.Forms.Padding(4);
		this.nudNumers.Maximum = new decimal(new int[4] { 1000, 0, 0, 0 });
		this.nudNumers.Minimum = new decimal(new int[4] { 1, 0, 0, 0 });
		this.nudNumers.Name = "nudNumers";
		this.nudNumers.Size = new System.Drawing.Size(88, 25);
		this.nudNumers.TabIndex = 1;
		this.nudNumers.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
		this.nudNumers.Value = new decimal(new int[4] { 1, 0, 0, 0 });
		this.buttonOK.Location = new System.Drawing.Point(92, 220);
		this.buttonOK.Margin = new System.Windows.Forms.Padding(4);
		this.buttonOK.Name = "buttonOK";
		this.buttonOK.Size = new System.Drawing.Size(100, 29);
		this.buttonOK.TabIndex = 2;
		this.buttonOK.Text = "确认";
		this.buttonOK.UseVisualStyleBackColor = true;
		this.buttonOK.Click += new System.EventHandler(buttonOK_Click);
		this.buttonCannel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
		this.buttonCannel.Location = new System.Drawing.Point(244, 220);
		this.buttonCannel.Margin = new System.Windows.Forms.Padding(4);
		this.buttonCannel.Name = "buttonCannel";
		this.buttonCannel.Size = new System.Drawing.Size(100, 29);
		this.buttonCannel.TabIndex = 3;
		this.buttonCannel.Text = "取消";
		this.buttonCannel.UseVisualStyleBackColor = true;
		this.buttonCannel.Click += new System.EventHandler(buttonCannel_Click);
		this.rdbNew.AutoSize = true;
		this.rdbNew.Checked = true;
		this.rdbNew.Location = new System.Drawing.Point(39, 22);
		this.rdbNew.Margin = new System.Windows.Forms.Padding(4);
		this.rdbNew.Name = "rdbNew";
		this.rdbNew.Size = new System.Drawing.Size(73, 19);
		this.rdbNew.TabIndex = 4;
		this.rdbNew.TabStop = true;
		this.rdbNew.Text = "新样品";
		this.rdbNew.UseVisualStyleBackColor = true;
		this.rdbNew.CheckedChanged += new System.EventHandler(rdbNew_CheckedChanged);
		this.rdbCopy.AutoSize = true;
		this.rdbCopy.Location = new System.Drawing.Point(39, 49);
		this.rdbCopy.Margin = new System.Windows.Forms.Padding(4);
		this.rdbCopy.Name = "rdbCopy";
		this.rdbCopy.Size = new System.Drawing.Size(43, 19);
		this.rdbCopy.TabIndex = 5;
		this.rdbCopy.Text = "从";
		this.rdbCopy.UseVisualStyleBackColor = true;
		this.rdbCopy.CheckedChanged += new System.EventHandler(rdbCopy_CheckedChanged);
		this.cbSampleAdd.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbSampleAdd.Enabled = false;
		this.cbSampleAdd.FormattingEnabled = true;
		this.cbSampleAdd.Location = new System.Drawing.Point(172, 45);
		this.cbSampleAdd.Margin = new System.Windows.Forms.Padding(4);
		this.cbSampleAdd.Name = "cbSampleAdd";
		this.cbSampleAdd.Size = new System.Drawing.Size(160, 23);
		this.cbSampleAdd.TabIndex = 6;
		this.cbSampleAdd.SelectedIndexChanged += new System.EventHandler(cbSampleAdd_SelectedIndexChanged);
		this.label2.AutoSize = true;
		this.label2.Location = new System.Drawing.Point(340, 48);
		this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label2.Name = "label2";
		this.label2.Size = new System.Drawing.Size(37, 15);
		this.label2.TabIndex = 7;
		this.label2.Text = "复制";
		this.groupBox1.Controls.Add(this.label2);
		this.groupBox1.Controls.Add(this.cbSampleAdd);
		this.groupBox1.Controls.Add(this.rdbCopy);
		this.groupBox1.Controls.Add(this.rdbNew);
		this.groupBox1.Location = new System.Drawing.Point(15, 15);
		this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
		this.groupBox1.Name = "groupBox1";
		this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
		this.groupBox1.Size = new System.Drawing.Size(399, 82);
		this.groupBox1.TabIndex = 8;
		this.groupBox1.TabStop = false;
		this.groupBox1.Text = "添加";
		this.groupBox2.Controls.Add(this.label3);
		this.groupBox2.Controls.Add(this.cbSamplePos);
		this.groupBox2.Controls.Add(this.rdbInsert);
		this.groupBox2.Controls.Add(this.rdbAppend);
		this.groupBox2.Location = new System.Drawing.Point(16, 130);
		this.groupBox2.Margin = new System.Windows.Forms.Padding(4);
		this.groupBox2.Name = "groupBox2";
		this.groupBox2.Padding = new System.Windows.Forms.Padding(4);
		this.groupBox2.Size = new System.Drawing.Size(399, 82);
		this.groupBox2.TabIndex = 9;
		this.groupBox2.TabStop = false;
		this.groupBox2.Text = "位置";
		this.label3.AutoSize = true;
		this.label3.Location = new System.Drawing.Point(339, 51);
		this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.label3.Name = "label3";
		this.label3.Size = new System.Drawing.Size(52, 15);
		this.label3.TabIndex = 7;
		this.label3.Text = "前插入";
		this.cbSamplePos.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbSamplePos.Enabled = false;
		this.cbSamplePos.FormattingEnabled = true;
		this.cbSamplePos.Location = new System.Drawing.Point(171, 48);
		this.cbSamplePos.Margin = new System.Windows.Forms.Padding(4);
		this.cbSamplePos.Name = "cbSamplePos";
		this.cbSamplePos.Size = new System.Drawing.Size(160, 23);
		this.cbSamplePos.TabIndex = 6;
		this.cbSamplePos.SelectedIndexChanged += new System.EventHandler(cbSamplePos_SelectedIndexChanged);
		this.rdbInsert.AutoSize = true;
		this.rdbInsert.Location = new System.Drawing.Point(38, 47);
		this.rdbInsert.Margin = new System.Windows.Forms.Padding(4);
		this.rdbInsert.Name = "rdbInsert";
		this.rdbInsert.Size = new System.Drawing.Size(43, 19);
		this.rdbInsert.TabIndex = 5;
		this.rdbInsert.Text = "在";
		this.rdbInsert.UseVisualStyleBackColor = true;
		this.rdbInsert.CheckedChanged += new System.EventHandler(rdbInsert_CheckedChanged);
		this.rdbAppend.AutoSize = true;
		this.rdbAppend.Checked = true;
		this.rdbAppend.Location = new System.Drawing.Point(38, 20);
		this.rdbAppend.Margin = new System.Windows.Forms.Padding(4);
		this.rdbAppend.Name = "rdbAppend";
		this.rdbAppend.Size = new System.Drawing.Size(103, 19);
		this.rdbAppend.TabIndex = 4;
		this.rdbAppend.TabStop = true;
		this.rdbAppend.Text = "在末尾追加";
		this.rdbAppend.UseVisualStyleBackColor = true;
		this.rdbAppend.CheckedChanged += new System.EventHandler(rdbAppend_CheckedChanged);
		base.AcceptButton = this.buttonOK;
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.CancelButton = this.buttonCannel;
		base.ClientSize = new System.Drawing.Size(425, 259);
		base.Controls.Add(this.groupBox2);
		base.Controls.Add(this.groupBox1);
		base.Controls.Add(this.buttonCannel);
		base.Controls.Add(this.buttonOK);
		base.Controls.Add(this.nudNumers);
		base.Controls.Add(this.label1);
		base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
		base.Margin = new System.Windows.Forms.Padding(4);
		base.MaximizeBox = false;
		base.MinimizeBox = false;
		base.Name = "FormAddSampleNumber";
		base.ShowIcon = false;
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
		this.Text = "添加样品数量";
		base.Load += new System.EventHandler(FormAddSampleNumber_Load);
		((System.ComponentModel.ISupportInitialize)this.nudNumers).EndInit();
		this.groupBox1.ResumeLayout(false);
		this.groupBox1.PerformLayout();
		this.groupBox2.ResumeLayout(false);
		this.groupBox2.PerformLayout();
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
